#!/bin/bash
#功能函数
funcs=./functions.sh
if test ! -f $funcs; then
    funcs=`which functions.sh`
    if [ "$funcs" = "" ]; then
        echo "functions.sh not exist!!"
        return
    else
        echo "funcs=$funcs"
	. $funcs
    fi
else
    echo "funcs=$funcs"
    . $funcs  
fi

function setup-common()
{
    echoTextBlue "安装基础软件......"
    result=`question "Configure system first time?" 1 no`
    if [ "$result" = "yes" ]; then
        sudo apt-get update
        sudo ln -svf /bin/bash /bin/sh
    fi
   
    sudo apt-get install iptux expect subversion
    #############################################   
    echoTextBlue "安装 Oracle VM VirtualBox......"
    if  ! sh_dpkg_status virtualbox-4.0;then 
        sh_wget http://download.virtualbox.org/virtualbox/4.0.2/virtualbox-4.0_4.0.2-69518~Ubuntu~maverick_i386.deb ~/downloads/
        sudo dpkg -i ~/downloads/virtualbox-4.0_4.0.2-69518~Ubuntu~maverick_i386.deb
        #2.系统->系统管理->用户和组。点选管理组，找到vboxusers，点选属性，将你自己的用户名勾选。
        #3.打开virtualbox，设置已安装的winxp，设置->USB设备，勾选“启用USB控制器”
        #http://qyiyunso.blog.163.com/blog/static/35077686201092653624956/
    fi
    #############################################    
    setup-xdmcp.sh
    echoTextBlue "安装支付宝控件......"
    sh_wget https://download.alipay.com/alipaysc/linux/aliedit/1.0.3.20/aliedit.tar.gz ~/downloads/
    tar -xvf ~/downloads/aliedit.tar.gz -C /tmp/
    sh /tmp/aliedit.sh
}


function setup-android()
{
    echoTextBlue "Begain to setup android env ......"
    setup-android.sh
}

function setup-all()
{
    echoTextBlue "Begain to setup setup_all ......"
    setup-common
    setup-android.sh -m auto
}

#脚步入口：解析参数
while test $# != 0
do
    case $1 in
	-r)
	    shift
	    version=$1
	    ;;
	-m)
	    shift
	    mode=$1
	    ;;
        *)
	    mode=$1
	    ;;
       esac
       shift
done

#判断安装模式
INSTALL_MODE=mannul
if [ -n "$mode" ]; then INSTALL_MODE=$mode; fi
export INSTALL_MODE

###########
echoTextBlue "Getting current Unbutu version from file: /etc/issue ......"
ubutu_version=`sh_get_ubuntu_version`
echoTextGreen "ubutu_version=$ubutu_version"
if [ "$INSTALL_MODE" = "auto" ]; then
    setup_common
    setup-network.sh -m  $INSTALL_MODE
else
    menu_list="setup-common setup-network.sh setup-android cryptsetup.sh setup-all"
    echoTextBlue "Please select"
    result=`sh_menu_select "$menu_list"`
    echo "${result}"
    ${result}
fi

exit










































sudo ln -svf /bin/bash /bin/sh
sudo apt-get install vim patch iptux subversion expect openoffice.org xpdf-reader
sudo apt-get install nfs-common nfs-kernel-server 
sudo apt-get install  virtualbox-ose virtualbox-guest-additions virtualbox-ose-dbg virtualbox-ose-guest-source virtualbox-ose-guest-utils virtualbox-ose-guest-x11

sudo /etc/init.d/virtualbox-ose start



sudo apt-get install mail
echo "body" | mail -s "subject" mohuifu@gmail.com -a "From: mohuifu@gmail.com"  

sudo apt-get install git-core gnupg  sun-java6-jdk flex bison gperf  libsdl-dev  libesd0-dev libwxgtk2.6-dev build-essential zip curl libncurses5-dev zlib1g-dev valgrind
sudo update-java-alternatives -s java-6-sun
sudo update-alternatives --config java 
sudo apt-get install libstdc++6-4.3-dev gcc-4.3 g++-4.3
sudo ln -svf /usr/bin/gcc-4.3 /usr/bin/gcc
sudo ln -svf /usr/bin/g++-4.3 /usr/bin/g++

if test ! -f /var/cache/apt/archives/cpp-4.3_4.3.4-5ubuntu1_i386.deb; then
sudo wget http://ftp.riken.go.jp/pub/Linux/ubuntu/pool/universe/g/gcc-4.3/cpp-4.3_4.3.4-5ubuntu1_i386.deb /var/cache/apt/archives/
sudo wget http://ftp.riken.go.jp/pub/Linux/ubuntu/pool/universe/g/gcc-4.3/gcc-4.3_4.3.4-5ubuntu1_i386.deb /var/cache/apt/archives/
sudo wget http://ftp.riken.go.jp/pub/Linux/ubuntu/pool/universe/g/gcc-4.3/libstdc++6-4.3-dev_4.3.4-5ubuntu1_i386.deb /var/cache/apt/archives/
sudo wget http://ftp.riken.go.jp/pub/Linux/ubuntu/pool/universe/g/gcc-4.3/g++-4.3_4.3.4-5ubuntu1_i386.deb /var/cache/apt/archives/
fi



sudo apt-get install testdisk
i FIX this problem with testdisk
Package testdisk
* dapper (admin): Partition scanner and disk recovery tool
6.1-1: amd64 i386 powerpc
The problem was in incorrect number of heads => incorrect number of cylinders
Disk /dev/hda: 41.1 GB, 41174138880 bytes
[U]16 heads, 63 sectors/track, 79780 cylinders
Units = cylinders of 1008 * 512 = 516096 bytes
testdisk sign, that the correct number must be 255 heads ... but cylinders are too much ...
the right method is to calculate it.
HEADS * SECTORS/TRACK * CYLINDERS * UNITS = BYTES
the disk /dev/hda is 40GB => number of cylinders must be ~5005
after this correction, partition table is fixed and all data is OK :D


#安装 ubuntu 10.10
sudo apt-get update && sudo apt-get install ubuntu-restricted-extras
sudo apt-get install samba

sudo apt-get install gvfs-backends libgnomevfs2-extra libsmbclient libwbclient0 mplayer nautilus-share python-smbc samba-common samba-common-bin smbclient
system-config-printer-common system-config-printer-gnome ubuntu-desktop winbind

sudo apt-get install samba-common libwbclient0





